package dao.impl;

import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;
import utils.JdbcUtils;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

public class BaseDao {
    private QueryRunner queryRunner = new QueryRunner();

    public <T> List<T> queryForList(Class<T> type, String sql, Object... args) throws SQLException {
        Connection connection = JdbcUtils.getConnection();
        return queryRunner.query(connection,sql, new BeanListHandler<T>(type),args);
    }

}
